<?php
header("centent-type:text/html;charset=utf-8");
include_once("/Classes/PHPExcel.php");
$excel=PHPExcel_IOFactory::load("data.xls");
//print_r($excel);
$s=$excel->getActiveSheet();
$r=$s->getHighestRow();
$c=$s->getHighestColumn();
for ($i=2;$i<=$r;$i++)
{
    for ($j='A';$j<=$c;$j++)
    {
        $data[$i-2][]=$s->getCell($j.$i)->getValue();
    }
}
$pdo=new PDO("mysql:host=127.0.0.1;dbname=test;charset=utf8",'root','root');

foreach ($data as $key=>$v)
{
    $name=$v[0];
    $pwd=$v[1];
    $zname=$v[2];
    $gong=$v[3];
    $sql="insert into class values(NULL ,'$name','$pwd','$zname','$gong')";
    //print_r($sql);die;
    $res=$pdo->exec($sql);
}
echo $res;

?>
